<?php namespace Admin\Controller; 

use Admin\AuthController;
use Admin\Model\Role;
class RoleController extends AuthController{
	//模型连接驱动 
	protected $db;
	//构造函数
	public function __init()
	{
		$this->db = new Role;
	}
	
    //动作
    public function index(){
       $data = Db::table('role')->get();
       View::with('data',$data);
       View::make();
    }
    //创建角色
    public function create()
    {
    	if(IS_POST)
    	{
    		if($this->db->store())
    		{
    			$this->success('添加成功了。。。','index');
    		}
    		else
    		{
    			$this->error($this->db->getError());
    		}
    	}
    	else
    	{
    		View::make();	
    	}
    }

    //角色修改
    public function edit()
    {
        if(IS_POST)
        {
           if($this->db->update())
           {
                $this->success('修改成功','index');
           }
           else
           {
                $this->error($this->db->getError());
           }
        }
        else
        {
            View::make();
        }
    }
}














